import 'dart:ui';

import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBBaseRouter/YBApplication.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBBaseRouter/YBNavigator.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBImageStyle/YBImageStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBHomePage/YBHomePageProvider/YBCitySelectEventBus.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBHomePage/YBSubPage/YBCitySelectPage.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBHomePage/YBSubPage/YBHomePageMainFPage.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBHomePage/YBSubPage/YBHomePageMainFourPage.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBHomePage/YBSubPage/YBHomePageMainSPage.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBHomePage/YBSubPage/YBHomePageMainTPage.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBHomePage/YBSubPage/yb_homePage_fourmainpage.dart';




class YBMainPage extends StatefulWidget {
  @override
  _YBMainPageState createState() => _YBMainPageState();
}

class _YBMainPageState extends State<YBMainPage> {

  String cityName = YBChineseText.homeTextAddress;

  @override
  void initState() {
    super.initState();
    YBCitySelectPage().requestLocation();
    eventBus.on<YBCitySelectEventBus>().listen((event) {
      setState(() {
        cityName = event.cityName;
      });
    });
  }

  @override
  Widget build(BuildContext context) {

    return Container(
      child: Scaffold(
        appBar: AppBar(
          elevation: 0,
          leading: Container(
            child: InkWell(
              child: Padding(
                padding: EdgeInsets.only(left: YBTextStyle.adapterSize10,),
                child: Row(
                  children: [
                    Expanded(
                      child: Text(cityName??'',style: YBTextStyle.TextStyle26272916Smebold,maxLines: 1,),
                    ),
                    Container(
                      child: Image.asset(YBImageStyle.getImagePath('shopping_locationImage')),
                    ),
                  ],
                ),
              ),
              onTap: () async {
                 YBCitySelectPage().clickTaggle(context);
              },
            ),
          ),
          //
          actions: [
            InkWell(
              child: Container(
                child: InkWell(
                  child: Image.asset(YBImageStyle.getImagePath('counmsel_qrcode')),
                  onTap: () async {
                    YBNavigatorUtil.jump(context, "/homePage/homePageScannPage");
                  },
                ),
              ),
            )
          ],
        ),
        body: SingleChildScrollView(
          child: Column(
            children: [
              YBHomePageMainFPage(),
              YBHomePageMainSPage(),
              YBHomePageMainTPage(),
            //  YBHomePageMainFourPage(),
              YBHomePageNewFourMainPage(),
              Container(
                height: YBTextStyle.adapterSize36,
              ),
            ],
          ),
        ),
      ),
    );
  }
}

